@extends('admin.layout')

@section('title')栏目管理@endsection

@section('content')
    <div class="page clearfix">

        <ol class="breadcrumb breadcrumb-small">
            <li>后台首页</li>
            <li><a href="{{ url('admin/article') }}">文章管理</a></li>
            <li><a href="{{ url('admin/article/create') }}">帖子添加</a></li>
        </ol>
        <div class="page-wrap">

            <div class="row">
                <div class="col-md-12">
                    <form id="form" action="{{ url('admin/article') }}" autocomplete="off" class="form-horizontal" method="post">
                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                        <div class="panel panel-lined clearfix mb30">
                            <div class="panel-heading mb20"><i>添加栏目</i></div>
                            <div class="col-md-12">

                                <div class="form-group form-group-sm">
                                    <label class="col-md-4 control-label">归属栏目</label>
                                    <div class="col-md-4">
                                        <select class="form-control areaSelect" name="cateid">
                                            @if( $parent )
                                                @foreach($parent as $item)
                                                    <option value="{{ $item['id'] }}">{{ $item['_name'] }}</option>
                                                @endforeach
                                            @endif
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group form-group-sm">
                                    <label class="col-md-4 control-label">帖子标题</label>
                                    <div class="col-md-4">
                                        <input type="text" class="form-control" name="name" value="{{ old('name') }}">
                                    </div>
                                </div>


                                <div class="form-group form-group-sm">
                                    <label class="col-md-4 control-label">背景及心情</label>
                                    <div class="col-md-4">
                                        <textarea  class="form-control" name="background">{{ old('background') }}</textarea>
                                    </div>
                                </div>


                                <div class="form-group form-group-sm">
                                    <label class="col-md-4 control-label">帖子内容</label>
                                    <div class="col-md-4" >
                                        <iframe id="iframe" class="embed-responsive-item" style="border:0px;width:800px;height: 535px;margin-left: -15px;" src="{{ url('admin/markdown') }}"></iframe>
                                    </div>
                                    <input type="hidden" name="content" id="rellaycontent"/>
                                </div>


                                <div class="form-group form-group-sm">
                                    <label class="col-md-4 control-label">展示图片</label>
                                    <div class="col-md-4">
                                        <input type="button" class="btn btn-info" id="button" value="选择图片">
                                        <input id="file" placeholder="上传图片或者输入网络图片" type="text" name="thumb" class="form-control"/>
                                    </div>
                                </div>

                                <div class="form-group form-group-sm">
                                    <label class="col-md-4 control-label">定时发布</label>
                                    <div class="col-md-4">
                                        <input id="tming" placeholder="时间格式：Y-m-d H:i:s" value="0" class="form-control"  name="tming"/>
                                    </div>
                                </div>


                                <div class="form-group form-group-sm">
                                    <label class="col-md-4 control-label">是否私有</label>
                                    <div class="col-md-4">
                                        <div class="btn-group" data-toggle="buttons">
                                            <label class="btn btn-primary ">
                                                <input type="radio" name="private" value="1" id="option2" autocomplete="off"> 私有
                                            </label>
                                            <label class="btn btn-primary active">
                                                <input type="radio" name="private" value="0" checked id="option3" autocomplete="off"> 公开
                                            </label>
                                        </div>
                                    </div>
                                </div>


                                <div class="form-group form-group-sm">
                                    <label class="col-md-4 control-label">状态</label>
                                    <div class="col-md-4">
                                        <div class="btn-group" data-toggle="buttons">
                                            <label class="btn btn-primary active">
                                                <input type="radio" name="status" checked value="1" id="option2" autocomplete="off"> 启用
                                            </label>
                                            <label class="btn btn-primary ">
                                                <input type="radio" name="status" value="0" id="option3" autocomplete="off"> 未启用
                                            </label>
                                        </div>
                                    </div>
                                </div>


                                <div class="form-group form-group-sm">
                                    <div class="col-md-4 col-md-offset-4">
                                        <button id="" type="submit"  class="btn btn-primary btn-sm" style="width: 100%;">提交</button>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
@endsection

@section('javascript')
    {{--引入moxie--}}
    <script type="text/javascript" src="{{ asset('assets/uploader/js/moxie.js') }}"></script>
    {{--引入plupload--}}
    <script type="text/javascript" src="{{ asset('assets/uploader/js/plupload.dev.js') }}"></script>
    {{--引入qiniu--}}
    <script type="text/javascript" src="{{ asset('assets/uploader/js/qinius.js') }}"></script>
    {{--上传配置--}}
    <script type="text/javascript" >

            /*获取markdown内容*/
            $('#form').submit(function()
            {
                var content = $("#iframe").contents().find('#myEditor').val();
                $('#rellaycontent').val(content);
            })

            /*notadd 配置*/
            var notadd;
            /*设置ajax请求为同步，否则结果无法给全局变量赋值*/
            $.ajaxSetup({async : false});
            /*请求结果*/
            $.get("{{ url('admin/QiniuList') }}",function(data)
            {
                eval('var data ='+data);
                notadd = data;
                /*点选按钮*/
                notadd.browse_button = 'button';
                /*赋值目标*/
                notadd.target = 'file';
            });

    </script>
    {{--引入notadd-ext-qiniu --}}
    <script type="text/javascript" src="{{ asset('assets/uploader/js/notadd-ext-qiniu.js') }}"></script>
@endsection
